package com.itheima.controller;

import com.itheima.pojo.Article;
import com.itheima.pojo.Category;
import com.itheima.pojo.Comment;
import com.itheima.pojo.Result;
import com.itheima.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/homepage/homepage/ArticleDetails")
public class CommentController {
	@Autowired
	private CommentService commentService;

	@PostMapping("/{articleId}")
	public Result add(@RequestBody Comment comment) {
		commentService.add(comment);
		return Result.success();
	}
	// /user/1  $route.param.id
	// /user?id=1  $route.query.id
	@GetMapping("/{id}")
	public  Result<List<Comment>> select(@PathVariable int id) {
		return Result.success(commentService.select(id));
    }

	//	根据id查询单个文章
//	@GetMapping("/homepage/ArticleDetails")
//	public Result<List<Article>> lists(Integer id) {
//		List<Article> article = homePageService.findById(id);
//		return Result.success(article);
//	}



}
